package com.tang.mapper;

import com.tang.pojo.Books;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface BookMapper {
    //增加一本书
    @Insert("insert into books(bookName, bookCounts, detail) values (#{bookName},#{bookCounts},#{detail});")
    int addBook(Books books);
    //删除一本书
    @Delete("delete from books where bookID=#{bookId};")
    int deleteBookById(@Param("bookId") int id);
    //更新一本书
    @Update(" update books set bookName=#{bookName},bookCounts=#{bookCounts},detail=#{detail} where bookID=#{bookID};")
    int updateBook(Books books);
    //查询一本书
    @Select("select * from books where bookID=#{id};")
    Books queryBookBookById(int id);
    //查询全部的书
    @Select("select * from books")
    List<Books> queryAllBook();
    //模糊查询
    @Select("select * from books where bookName like concat('%',#{bookName},'%');")
    List<Books> queryBookByName(String bookName);
}
